Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pose proposal: support rotation in degrees (#252) #589

Merged
merged 36 commits into from
Sep 2, 2021

Conversation

aaronchongth
Copy link
Collaborator

@aaronchongth aaronchongth commented Jun 11, 2021

🎉 New feature

Related to #252. This has been considered as more favorable than #581 (closed).

Summary

  • Param values can now be parsed differently according to their parent Element's attributes. This is being used by Pose in this PR.
  • The rotation units can now be parsed as degrees with the attribute //pose[@degrees='true'], otherwise it is parsed as radians by default.
  • Added tests to handle additional spaces or newlines as delimiters between translation and rotation values.

Valid poses look like so,

<!-- Pose with rotation units in radians -->
<pose>1 2 3   0.4 0.5 0.6</pose>

<!-- Pose with rotation units in radians -->
<pose degrees="false">1 2 3   0.4 0.5 0.6</pose>

<!-- Pose with rotation units in degrees -->
<pose degrees="true">1 2 3   0.4 0.5 0.6</pose>

<!-- Single space delimiter -->
<pose>1 2 3 0.4 0.5 0.6</pose>

<!-- Multiple space delimiters -->
<pose>1 2 3   0.4 0.5 0.6</pose>

<!-- Newline delimiters -->
<pose>
  1 2 3
  0.4 0.5 0.6
</pose>

Implementation details,

  • Added API for SetParentElement and GetParentElement, modified Element::Clone, Element::Copy to handle setting parent elements for each child value or attribute.
  • Added Reparse function to Param, to be called when parent Element attributes have been changed manually, and changes to its value need to be reflected.
  • SetParentElement attempts to reparse previous string-ified values using new parent element attributes.
  • Added ignoreParentAttribute flag, for when the value of the Param was set explicitly using the Set<T> function. The desired behavior would be that explicitly set values should not be affected by Reparse, while values SetFromString, should take into account of parent Element attributes.

Test it

source install/setup.bash
colcon test --merge-install --packages-select sdformat12
colcon test-result

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Code check passed (In source directory, run sh tools/code_check.sh)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review
    another open pull request
    to support the maintainers

Note to maintainers: Remember to use Squash-Merge

@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Jun 11, 2021
@aaronchongth aaronchongth requested a review from azeey June 11, 2021 10:35
@aaronchongth aaronchongth force-pushed the aaron/pose-configurable-rotation branch from bd76451 to 01b01d6 Compare June 11, 2021 10:57
@azeey
Copy link
Collaborator

azeey commented Jun 25, 2021

@aaronchongth My understanding according the the updated proposal was that the "simpler" implementation would use the //pose/@rotation_type attribute instead of //pose/translation and //pose/rotation. So for the examples you gave, it would be:

<!-- Read as (x y z roll pitch yaw), with rotation in radians -->
<pose>1 2 3   0.4 0.5 0.6</pose>

<!-- Read as (x y z roll pitch yaw), with rotation in radians -->
<pose rotation_type="rpy_radians">1 2 3   0.4 0.5 0.6</pose>

<!-- Read as (x y z roll pitch yaw), with rotation in degrees -->
<pose rotation_type="rpy_degrees">1 2 3   0.4 0.5 0.6</pose>

<!-- Read as (x y z W X Y Z), with rotation in quaternions -->
<pose rotation_type="rpy_qwxyz">1 2 3   0.707 0.707 0 0</pose>

Do you mind updating this PR to support //pose/@rotation_type?

@aaronchongth
Copy link
Collaborator Author

aaronchongth commented Jun 28, 2021

Thanks for pointing it out, @azeey! I have just made the changes, and tried to adhere more to the proposal, 8480dd6

@aaronchongth aaronchongth force-pushed the aaron/pose-configurable-rotation branch from 95da234 to 8480dd6 Compare June 28, 2021 08:43
@codecov-commenter
Copy link

codecov-commenter commented Jun 28, 2021

Codecov Report

Merging #589 (36d9f6b) into main (6a6aba1) will decrease coverage by 0.07%.
The diff coverage is 71.11%.

❗ Current head 36d9f6b differs from pull request most recent head 8480dd6. Consider uploading reports for the commit 8480dd6 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #589      +/-   ##
==========================================
- Coverage   87.54%   87.46%   -0.08%     
==========================================
  Files          72       72              
  Lines       10514    10557      +43     
==========================================
+ Hits         9204     9234      +30     
- Misses       1310     1323      +13     
Impacted Files Coverage Δ
src/Param.cc 89.56% <65.78%> (-2.80%) ⬇️
src/Utils.cc 86.56% <100.00%> (+0.62%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a6aba1...8480dd6. Read the comment docs.

@EricCousineau-TRI
Copy link
Collaborator

EricCousineau-TRI commented Jun 28, 2021

<!-- Read as (x y z   W X Y Z), with rotation in quaternions, this is an interesting case, more explanations below -->
<pose>1 2 3   0.707 0.707 0 0</pose>

This has a weird smell; I think this code (if it works) is doing too much. If @rotation_type isn't specified, then the semantics should only be that of rpy_radians; nothing additional should be inferred from malformed / different sized values, IMO.
Otherwise, an innocent typo can be accepted in a very confusing way.

Copy link
Collaborator

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass done, PTAL!

src/Param.cc Outdated Show resolved Hide resolved
src/Utils.cc Outdated Show resolved Hide resolved
src/Utils.cc Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jul 8, 2021

Codecov Report

Merging #589 (95c292e) into main (c919d23) will decrease coverage by 0.08%.
The diff coverage is 80.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #589      +/-   ##
==========================================
- Coverage   87.98%   87.90%   -0.09%     
==========================================
  Files          72       72              
  Lines       10929    11022      +93     
==========================================
+ Hits         9616     9689      +73     
- Misses       1313     1333      +20     
Impacted Files Coverage Δ
include/sdf/Element.hh 100.00% <ø> (ø)
src/Param.cc 89.18% <77.01%> (-3.31%) ⬇️
include/sdf/Param.hh 77.14% <100.00%> (ø)
src/Element.cc 96.82% <100.00%> (+0.06%) ⬆️
src/parser.cc 84.93% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c919d23...95c292e. Read the comment docs.

Copy link
Collaborator

@azeey azeey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. I have a few minor comments. Can you also fix the merge conflicts when you get a chance?

include/sdf/Element.hh Outdated Show resolved Hide resolved
sdf/1.9/actor.sdf Outdated Show resolved Hide resolved
sdf/1.9/inertial.sdf Outdated Show resolved Hide resolved
sdf/1.9/urdf.sdf Outdated Show resolved Hide resolved
src/Element.cc Outdated Show resolved Hide resolved
src/Param.cc Outdated Show resolved Hide resolved
src/Param.cc Outdated Show resolved Hide resolved
src/Param.cc Outdated Show resolved Hide resolved
src/Param.cc Outdated Show resolved Hide resolved
test/integration/param_parent_element.cc Outdated Show resolved Hide resolved
@aaronchongth aaronchongth changed the title New pose proposal - minimal (#252) New pose proposal (#252) Jul 26, 2021
@aaronchongth aaronchongth force-pushed the aaron/pose-configurable-rotation branch from bdfbcb9 to d4c8dcf Compare July 26, 2021 09:32
@azeey
Copy link
Collaborator

azeey commented Aug 30, 2021

Per VC, Aaron to fix printing of poses so that if degrees=true, poses will be printed in degrees.

@aaronchongth aaronchongth force-pushed the aaron/pose-configurable-rotation branch from c69920f to 40f2575 Compare August 31, 2021 06:24
@aaronchongth aaronchongth force-pushed the aaron/pose-configurable-rotation branch from 40f2575 to 9ac3504 Compare August 31, 2021 16:32
@aaronchongth
Copy link
Collaborator Author

Thanks for the note, @azeey! This commit 9ac3504 should be fixing the problem and contains some tests too. The expected values from certain models in other tests have changed as well, I have made the necessary changes.

Copy link
Collaborator

@azeey azeey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Just a few more minor comments.

include/sdf/Param.hh Outdated Show resolved Hide resolved
src/Param.cc Outdated Show resolved Hide resolved
src/Param.cc Outdated Show resolved Hide resolved
include/sdf/Param.hh Outdated Show resolved Hide resolved
@aaronchongth aaronchongth force-pushed the aaron/pose-configurable-rotation branch from e901780 to 8602180 Compare September 2, 2021 06:18
@aaronchongth aaronchongth requested a review from azeey September 2, 2021 08:14
src/Param.cc Outdated Show resolved Hide resolved
@aaronchongth aaronchongth requested a review from azeey September 2, 2021 17:06
Copy link
Collaborator

@azeey azeey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@aaronchongth aaronchongth merged commit 96ac74e into main Sep 2, 2021
@aaronchongth aaronchongth deleted the aaron/pose-configurable-rotation branch September 2, 2021 17:25
@scpeters scpeters mentioned this pull request Sep 10, 2021
7 tasks
azeey added a commit that referenced this pull request Dec 20, 2024
Reparse was added in #589 to deal with the possibility that the meaning of an Element's value depends on the attributes in the element and those attributes might be different when reparenting. However, this does not apply when cloning since there will be no change in the attributes in the cloned element.

---------

Signed-off-by: Arjo Chakravarty <[email protected]>
Signed-off-by: Arjo Chakravarty <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
Co-authored-by: Steve Peters <[email protected]>
Co-authored-by: Addisu Z. Taddese <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants